<?php

	class OrderCoeff extends Order_coeff_model {

		function __construct() {
			parent::__construct();
		}
                
                function getCalculatedPrices($unit_price, $decimals = 2) {
                    $prices_list = new OrderCoeff();
                    $prices_list->addSelect();
                    $prices_list->addSelect("order_coeff.coeff, order_coeff.target, IF(order_coeff.is_used > 0, 
                            ROUND((1 - order_coeff.coeff) * order_coeff.target * $unit_price, $decimals), 0) price,
                            IF(order_coeff.is_used = 0, 'FREE', ROUND((1 - order_coeff.coeff) * order_coeff.target
                            * $unit_price, $decimals)) price_display");
                    $prices_list->addWhere('order_coeff.is_deleted = '.IS_NOT_DELETED);
                    $prices_list->find();
                    
                    return $prices_list->countRows() > 0 ? $prices_list : false;
                }
	}
